package com.web.base.log.service;

import com.blue.jdbc.JdbcDataSource;
import com.blue.jdbc.Page;
import com.web.base.log.dao.MessageDao;
import com.web.base.log.model.Message;
import com.web.core.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 消息业务层
 * 
 * @author 代码由 blue-code 框架生成
 * @since 1.0 2018年06月20日
 */
@Service("logMessageService")
@Transactional
@JdbcDataSource(Const.DS_BASE)
public class MessageService
{
	@Autowired
	private MessageDao messageDao;
	
	public MessageService()
	{
	}
	
	public Message save(Message message)
	{
		if (message.getId() == null)
		{
			messageDao.save(message);
		}
		else
		{
			messageDao.update(message);
		}
		Message a = messageDao.get(message.getId());
		return a;
	}
	
	public Message get(Integer id)
	{
		Message message = messageDao.get(id);
		return message;
	}
	
	public Page<Message> list(Message message, Page<Message> page)
	{
		page = messageDao.list(message, page);
		return page;
	}

	public void delete(Message message)
	{
		messageDao.delete(message);
	}
	
}
